package com.zzg.processor;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.webmagic.selector.Html;

public class FoodWorldDetailProcessor implements PageProcessor {

	 // 抓取网站的相关配置，包括编码、重试次数、抓取间隔、超时时间、请求消息头、UA信息等
    private Site site= Site.me().setRetryTimes(3).setSleepTime(1000).setTimeOut(3000)
            .setUserAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36");
	
	@Override
	public void process(Page page) {
		// TODO Auto-generated method stub
		Html html = page.getHtml();
		Document doc = html.getDocument();
		// 根节点
		// 查询div的class为space_left的标签
		Element root = doc.select("div.space_left").first();
		// 查询div的class为userTop clear的标签   > a标签的href 属性
		String auth_href = root.select("div.userTop.clear > a").first().attr("href");
		// 查询div的class为userTop clear的标签   > a标签  > img 标签的src 属性
		String auth_head_path = root.select("div.userTop.clear > a > img").first().attr("src");
		
		//查询详情图片
		String picture = root.select("div.space_box_home > div.recipDetail > div.recipe_De_imgBox > a > img").first().attr("src");
		// 主料
		
	}

	@Override
	public Site getSite() {
		// TODO Auto-generated method stub
		return site;
	}

}
